package com.example.demo.mapper;

import com.example.demo.entity.Notation;
import com.example.demo.entity.TheoryKnowledge;
import com.example.demo.util.FileUtil;
import org.apache.ibatis.annotations.*;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.multipart.MultipartFile;


import java.util.List;


@Mapper
public interface TheoryKnowledgeMapper {

    //查找所有乐理知识信息
    @Select("select * from theory_knowledge_tb")
    List<TheoryKnowledge> findTheoryKnowledgeAll();

    //根据id查找乐理知识
    @Select("select * from theory_knowledge_tb where theory_knowledge_id = #{theory_knowledge_id}")
    TheoryKnowledge findTheoryKnowledgeById(Integer theory_knowledge_id);

    //添加乐理知识信息
    @Insert("insert into theory_knowledge_tb (name,type,cover_image,description,theory_knowledge_image) values (#{name},#{type},#{cover_image},#{description},#{theory_knowledge_image})" )
    Integer insertTheoryKnowledge(TheoryKnowledge theoryKnowledge);

    //修改曲谱信息
    @Update("update theory_knowledge_tb set name=#{name}, type=#{type}, cover_image=#{cover_image},description=#{description},theory_knowledge_image=#{theory_knowledge_image} where theory_knowledge_id=#{theory_knowledge_id}")
    Integer updateTheoryKnowledge(TheoryKnowledge theoryKnowledge);

    //删除曲谱信息
    @Delete("delete from theory_knowledge_tb where theory_knowledge_id = #{theory_knowledge_id}")
    Integer deleteTheoryKnowledge(Integer theory_knowledge_id);

    @Select("SELECT * FROM theory_knowledge_tb ORDER BY view_count DESC LIMIT 5")
    List<TheoryKnowledge> findHotKnowledges();

}
